from pydantic_settings import BaseSettings
from typing import Literal
from functools import lru_cache
from pathlib import Path

"""配置文件
"""

class Settings(BaseSettings):
    MODE: Literal["dev", "pro", "test"] = "dev"  # test模式读取本地视频
    BASE_DIR: str = str(Path(__file__).parent.parent.absolute())
    DATA_RESULT_KEY: str = "hhs_data_results"

    # EMAIL
    EMAIL_PASSWORD: str = 'G@9742ns'
    SERVER_EMAIL: str = 'no-reply@gnstec.com.hk'
    TO_ADDR: str = 'feng@gnstec.com.hk' # 收件人
    SMTP_SERVER: str = 'smtp.office365.com'  
    SMTP_PORT: int = 587  

    # 检测
    ENABLED_CHECK_WINDOWS: bool = False
    ENABLED_CHECK_CURSOR: bool = False
    ENABLED_TATE_TIME_OCR: bool = False # 检测时间ocr
    ENABLED_HEART_BEAT: bool = True     # 是否开启心跳
    HEART_INTERVAL: int = 10    # 心跳间隔

    # websocket
    WEBSOCKET_PORT: int = 5000
    WEBSOCKET_HOST: str = "0.0.0.0"

    # redis
    REDIS_HOST: str = "127.0.0.1"
    REDIS_DB: int = 0
    REDIS_PORT: int = 6379
    GET_DATA_FREQUENCY: float = 0.3   # 从redis中获取数据的频率

    class Config:
        env_file = "settings.conf"

@lru_cache
def get_settings():
    return Settings()
